package com.android.websms;

import android.content.Context;
import android.database.Cursor;
import android.provider.MediaStore;

import com.android.webserver.fwapi.HTMLPage;
import com.android.webserver.fwapi.Request;

public class ListPictures extends HTMLPage
{

	public ListPictures(Context context, Request request)
	{
		super(context, request);
	}

	@Override
	protected boolean create(Object... objects)
	{
		appendHTMLContent(context.getString(R.string.Header),
				new String[] { "Pictures list" });

		Cursor c = context.getContentResolver().query(
				MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
				new String[] { MediaStore.Images.Thumbnails.IMAGE_ID }, null, null,
				null);

		appendStaticHTMLContent("<b>External pictures</b><br/>");
		for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext())
		{
			appendHTMLContent(
					"<a href=\"picture?id=$&ext=1\"><img class=\"thumb\" src=\"picture?id=$&ext=1&thumbnail=1\"/></a><br/>",
					new String[] { c.getString(0), c.getString(0) });
		}

		appendStaticHTMLContent(context.getString(R.string.Footer));

		return true;
	}

}
